<template>
   <div>
    <MyHeader title="我的购物车案例" :color="colorStr" :bgc="bgc"></MyHeader>
    <div class="main">
      <MyGoods v-for="item in list" :key="item.id"
       :obj="item"
      ></MyGoods>
    </div>
    <MyFooter :list="list"></MyFooter>
  </div>
</template>

<script>
import MyHeader from './components/MyHeader'
import MyGoods from './components/MyGoods'
import MyFooter from './components/MyFooter'
// 1自定义头部
//2 axios请求
// 渲染数据，循环组件，并把数组每一个对象传过去
// 3底部全选事件,计算属性,总价计算属性
export default {
  components: {
    MyHeader,
    MyGoods,
    MyFooter
  },
  data() {
    return {
      colorStr:'pink',
      bgc: '#eee',
      list:[]
    }
  },
  created(){
    this.$axios({
      url:'/api/cart'
    }).then(res =>{
      console.log(res);
      this.list = res.data.list
    })
  }
}
</script>

<style>
  .main{
    padding-top: 45px;
    padding-bottom: 50px;
  }
</style>